package com.zgjkhis.modules.system.service.mapper;

import com.zgjkhis.common.mapper.CoreMapper;
import com.zgjkhis.modules.system.domain.DrugInventory;
import com.zgjkhis.modules.system.service.dto.DrugInventoryQueryCriteria;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author yzq
 * @Description 盘点单
 * @Date 2021/6/23 9:48
 * @Param
 * @return
 **/
@Repository
public interface DrugInventoryMapper extends CoreMapper<DrugInventory> {


    @Select("<script>select * from his_drug_inventory t\n" +
            "where 1=1 and t.pharmacy_id=#{inventory.pharmacyId}\n" +
            "<if test=\"inventory.InventoryNo!=null and inventory.inventoryNo !=''\">\n" +
            "and t.inventory_no=#{inventory.inventoryNo}\n" +
            "</if>\n" +
            "<if test=\"inventory.InventoryName!=null and inventory.inventoryName !=''\">\n" +
            "and t.create_user_name=#{inventory.inventoryName}\n" +
            "</if>\n" +
            "<if test=\"inventory.inventoryType!=null\">\n" +
            "and t.inventory_type=#{inventory.inventoryType}\n" +
            "</if>\n" +
            "<if test=\"inventory.startTime !=null \">\n" +
            "and t.create_time  &gt; #{inventory.startTime}\n" +
            "</if>\n" +
            "<if test=\"inventory.endTime !=null \">\n" +
            "and t.create_time    &lt;  str_to_date(DATE_ADD(#{inventory.endTime},INTERVAL 1 DAY), '%Y-%m-%d %H')\n" +
            "</if></script>")
    List<DrugInventory> findAllByPageable(@Param("inventory") DrugInventoryQueryCriteria criteria);

}
